package iosr11.Service;

import java.util.logging.Logger;

import com.google.gdata.client.contacts.ContactsService;

public class UserAuthenticationServiceImpl implements UserAuthenticationService{
	private static String TITLE = "GABLE_user_auth";
	private Logger log = Logger.getLogger("service-log");
	
	public boolean authenticate(String login, String password){
		
		if(!login.contains("@")){
			login.concat("@gmail.com");
		}
				
		ContactsService service = new ContactsService(TITLE);
		
		try{
			service.setUserCredentials(login, password);
		}
		catch (Exception e){
			e.printStackTrace();
			log.warning("Nie udalo sie zalogowac do konta uzytkownika " + login);
			return false;
		}
		return true;
		
	}
}
